#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  char const *pwd = getenv("PWD");
  if (pwd == NULL)
    return 1;

  char const *home = getenv("HOME");
  if (pwd == NULL)
    return 1;

  size_t home_len = strlen(home);

  char const *show_cwd;
  bool starts_with_home = strncmp(home, pwd, home_len) == 0;

  if (starts_with_home) {
    show_cwd = pwd + home_len;
  } else {
    show_cwd = pwd;
  }

  size_t show_cwd_len = strlen(show_cwd);
  size_t width = 60;

  printf("color: blue\n");

  if (starts_with_home) {
    printf("text: ~");
  } else {
    printf("text: ");
  }

  if (show_cwd_len > width) {
    printf("...%s\n", show_cwd + (show_cwd_len - width));
  } else {
    printf("%s\n", show_cwd);
  }
  printf("color: reset\n");

  return 0;
}
